From 26886d1cc31279e76e036ae4f350b9534f916bb8 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 3 May 2006 07:44:20 +0100 Subject: [PATCH] Turn page-structure layout assertions into BUILD_BUG_ON(). Signed-off-by: Keir Fraser --- xen/arch/x86/x86_32/mm.c | 15 ++++----------- xen/arch/x86/x86_64/mm.c | 18 +++++------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/x86_32/mm.c b/xen/arch/x86/x86_32/mm.c index 519d744aac..73457ee036 100644 --- a/xen/arch/x86/x86_32/mm.c +++ b/xen/arch/x86/x86_32/mm.c @@ -155,17 +155,10 @@ void subarch_init_memory(void) * 64-bit operations on them. Also, just for sanity, we assert the size * of the structure here. */ - if ( (offsetof(struct page_info, u.inuse._domain) != - (offsetof(struct page_info, count_info) + sizeof(u32))) || - ((offsetof(struct page_info, count_info) & 7) != 0) || - (sizeof(struct page_info) != 24) ) - { - printk("Weird page_info layout (%ld,%ld,%d)\n", - offsetof(struct page_info, count_info), - offsetof(struct page_info, u.inuse._domain), - sizeof(struct page_info)); - BUG(); - } + BUILD_BUG_ON(offsetof(struct page_info, u.inuse._domain) != + (offsetof(struct page_info, count_info) + sizeof(u32))); + BUILD_BUG_ON((offsetof(struct page_info, count_info) & 7) != 0); + BUILD_BUG_ON(sizeof(struct page_info) != 24); /* M2P table is mappable read-only by privileged domains. */ for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++ ) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index c5247bea63..5560adb858 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -145,19 +145,11 @@ void subarch_init_memory(void) * count_info and domain fields must be adjacent, as we perform atomic * 64-bit operations on them. */ - if ( ((offsetof(struct page_info, u.inuse._domain) != - (offsetof(struct page_info, count_info) + sizeof(u32)))) || - ((offsetof(struct page_info, count_info) & 7) != 0) || - (sizeof(struct page_info) != - (32 + BITS_TO_LONGS(NR_CPUS)*sizeof(long))) ) - { - printk("Weird page_info layout (%ld,%ld,%ld,%ld)\n", - offsetof(struct page_info, count_info), - offsetof(struct page_info, u.inuse._domain), - sizeof(struct page_info), - 32 + BITS_TO_LONGS(NR_CPUS)*sizeof(long)); - for ( ; ; ) ; - } + BUILD_BUG_ON(offsetof(struct page_info, u.inuse._domain) != + (offsetof(struct page_info, count_info) + sizeof(u32))); + BUILD_BUG_ON((offsetof(struct page_info, count_info) & 7) != 0); + BUILD_BUG_ON(sizeof(struct page_info) != + (32 + BITS_TO_LONGS(NR_CPUS)*sizeof(long))); /* M2P table is mappable read-only by privileged domains. */ for ( v = RDWR_MPT_VIRT_START; -- 2.30.2